const header = new Map()
    .set('houseName', '所在机房')
    .set('ip', '应用IP')
    .set('findDomainListDomain', '子域名')
    .set('topDomain', '顶级域名')
    .set('visitsCount', '访问量')
    .set('recordNumber', '解析IP/备案号')
    .set('reportStatus', '上报状态')
    .set('findDomainListFirstTime', '首次采集时间')
    .set('findDomainListLastTime', '最后活跃时间')


const app = new BasicTableVue({
    data() {
        return {
            api:slogHotDomainApi,
            columns: [
                new TableColumn({width: 30, type: 'selection'}),
                new TableColumn({prop: 'houseName', title: '所在机房'}),
                new TableColumn({prop: 'ip', title: '应用IP'}),
                new TableColumn({prop: 'findDomainListDomain',title: '子域名',}),
                new TableColumn({prop: 'topDomain',title: '顶级域名',}),
                new TableColumn({prop: 'visitsCount', title: '访问量'}),
                new TableColumn({prop: 'recordNumber', title: '解析IP/备案号'}),
                new TableColumn({
                    prop: 'reportStatus',
                    title: '上报状态',
                    formatter: fieldFormatter.facade(fieldFormatter.hotDomain.reportStatusMap),
                }),
                new TableColumn({prop: 'findDomainListFirstTime', title: '首次采集时间' ,formatter: TableColumn.datetimeFormat } ),
                new TableColumn({prop: 'findDomainListLastTime', title: '最后活跃时间' ,formatter: TableColumn.datetimeFormat }),
            ],
            reportStatuslist:{'0':'未上报','1':'已上报'},

            positions: [],
            msgInfo :'',
            reportNum :'',
            isreportShow: false,
            timeArray1:[],
            timeArray2:[],
        }
    },
    methods: {
        createForm() {
            return new HotDomain({
                findDomainListDomain: forward.getData().content,
            })
        },
        changeFirstTime(timeArray) {
            [start, end] = timeArray || [];
            this.form.findDomainListFirstTimeStart = start
            this.form.findDomainListFirstTimeEnd = end
        },
        changeLastTime(timeArray) {
            [start, end] = timeArray || [];
            this.form.findDomainListLastTimeStart = start
            this.form.findDomainListLastTimeEnd = end
        },
        init() {
           this.initHouseMap();
        },
        initHouseMap: async function () {
            this.positions = await baseHouseInfoApi.selectList()
        },
        async reportShow() {
            const dataList = this.selectedList.filter(obj => parseInt(obj.reportStatus) == 0)
            const len = dataList.length;
            this.selectedList = dataList;
            if (len == 0) {
                await rxPrompt.msg('请勾选未上报的数据')
                return;
            }
            this.reportNum = len;
            this.isreportShow = true;
        },
        /**
         * 确认上报
         * @returns {Promise.<void>}
         */
        report: async function () {
            const res = await slogHotDomainApi.reportData(this.selectedList);
            if (res) {
                if (res.data) {
                    await rxPrompt.msg('上报成功');
                    this.isreportShow = false;
                    return;
                }
            }
            await rxPrompt.msg('上报失败,请稍后再试!')
        },
        /**
         * 重置确认上报
         */
        resetReport: function () {
            // console.log("resetReport");
            this.selectedIdList=[];
            this.mgInfo='';
            this.reportNum='没有符合规则活跃域名';
        },
    },



})
